package com.kaguya.vams.config.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * mybatis-plus自动填充
 * @author : kaguya
 * @date : 8:40 2021/8/4
 */
@Component
public class MPMetaObjectHandler implements MetaObjectHandler {

    //mp执行修改操作，这个方法执行
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("created", LocalDateTime.now(),metaObject);
        this.setFieldValByName("updated",LocalDateTime.now(),metaObject);
    }

    //mp执行修改操作，这个方法执行
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updated",LocalDateTime.now(),metaObject);
    }
}
